import Component from "@glimmer/component";
import { inject as service } from "@ember/service";

export default class HeaderSearch extends Component {
  @service site;
  @service router;
  @service siteSettings;
  @service currentUser;

  constructor() {
    super(...arguments);
    
    $(document).ready(function() {
        // 修改use icon中的 href为新的icon
        $(".searching > button > svg > use").attr("href", "#search");      
        // 修改svg为float
        $(".searching > button > svg").css("float", "right");  
    });
  }

  get displayForUser() {
    return (
      (this.siteSettings.login_required && this.currentUser) ||
      !this.siteSettings.login_required
    );
  }

  get shouldDisplay() {
    return (
      this.displayForUser &&
      !this.site.mobileView &&
      !this.router.currentRoute.name.includes("topic")
    );
  }
}
